package cn.tedu.straw.portal.service.impl;

import cn.tedu.straw.portal.dto.InserDTO;
import cn.tedu.straw.portal.dto.UpdateDTO;
import cn.tedu.straw.portal.mapper.ListuserMapper;
import cn.tedu.straw.portal.model.Listuser;
import cn.tedu.straw.portal.service.IListuserService;
import cn.tedu.straw.portal.vo.ClubVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tedu.cn
 * @since 2020-11-22
 */
@Service
public class ListuserServiceImpl extends ServiceImpl<ListuserMapper, Listuser> implements IListuserService {

    @Autowired
    ListuserMapper listuserMapper;

    @Override
    public List<ClubVO> getClubList() {

        return listuserMapper.findAll();
    }

    @Override
    public void listinsert(InserDTO InserVo) {
        Listuser listuser=new Listuser();
        listuser.setClubname(InserVo.getClubname());
        listuser.setName(InserVo.getName());
        listuser.setClubtype(InserVo.getClubtype());
        String date = InserVo.getTime();
        SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
        Date data = null;
        try {
            data = s.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        listuser.setTime(data);
        listuser.setAcount(InserVo.getAcount());
        listuser.setVcount(InserVo.getVcount());
        listuserMapper.insert(listuser);
    }

    @Override
    public void update(UpdateDTO updateDTO) {
        Listuser listuser=new Listuser();

       listuserMapper.update(updateDTO);
    }

    @Override
    public void delete(Integer id) {
        listuserMapper.delete(id);
    }


}
